<?php
if (!empty($_POST['save'])) {
	            //modification du nom de la marque 
			$brand=Brand::getFromName($_SESSION['vendor']['nom']);
			$brand->load();
			$brand['nom']=$_POST['name'];
			
			$brand->save();

				//modification du vendeur
		
			$_SESSION['vendor']['nom']=$_POST['name'];
			$_SESSION['vendor']['raison_sociale']=$_POST['social'];
			$_SESSION['vendor']['forme']=$_POST['form'];
			$_SESSION['vendor']['siret']=$_POST['siret'];
			$_SESSION['vendor']['tva_intra']=$_POST['num_tva'];
			
			$_SESSION['vendor']['adresse']=$_POST['adress'];
			$_SESSION['vendor']['cp']=$_POST['cp'];
			$_SESSION['vendor']['ville']=$_POST['city'];
			$_SESSION['vendor']['responsable']=$_POST['contact'];
			$_SESSION['vendor']['tel']=$_POST['tel'];
			$_SESSION['vendor']['tel_portable']=$_POST['mobile'];
			$_SESSION['vendor']['rib1']=$_POST['rib1'];
			$_SESSION['vendor']['rib2']=$_POST['rib2'];
			$_SESSION['vendor']['rib3']=$_POST['rib3'];
			$_SESSION['vendor']['rib4']=$_POST['rib4'];
			
			
			
			if(!empty($_SESSION['sharing'])){
				$_SESSION['sharing']['name']=$_POST['name'];
				$_SESSION['sharing']['email']=$_POST['login'];
				if ((!empty($_POST['pass']))&&(!empty($_POST['pass2']))) {
					$_SESSION['sharing']['password']=md5($_POST['pass']);
				}
				$_SESSION['sharing']->save();
				
			}
			
			
			if ((!empty($_POST['pass']))&&(!empty($_POST['pass2']))) {
				if($_POST['pass']==$_POST['pass2']) {
						$_SESSION['vendor']['password']=md5($_POST['pass']);
				}
			}
			
			
			
				if ((!empty($_POST['pass']))&&(!empty($_POST['pass2']))&&($_POST['pass']==$_POST['pass2'])&&($_SESSION['vendor']['email']==$_POST['login'])) {

						$mail = new Mail();
						$mail->setTo('admin@e-citizen.com');
						$array=array();	
						$array['vendor']=$_SESSION['vendor']['nom'];
						$array['password']=$_POST['pass'];
						$mail->setContent(login, $array);
						$mail->setSubject('Modification de mot de passe');
						$mail->send();
						
						$mailrose= new Mail();
						$mailrose->setTo('rmjuteau@gmail.com');
						$array=array();	
						$array['vendor']=$_SESSION['vendor']['nom'];
						$array['password']=$_POST['pass'];
						$mailrose->setContent(login, $array);
						$mailrose->setSubject('Modification de mot de passe');
						$mailrose->send();
						

					
				}
				elseif ((!empty($_POST['pass']))&&(!empty($_POST['pass2']))&&($_POST['pass']==$_POST['pass2'])&&($_SESSION['vendor']['email']!=$_POST['login'])){
						$mail = new Mail();
						$mail->setTo('admin@e-citizen.com');
						$array['vendor']=$_SESSION['vendor']['nom'];
						$array['password']=$_POST['pass'];
						$array['login']=$_POST['login'];
						
						$mail->setContent(login, $array);
						
						
						
						$mail->send();
						
						
						$mailrose= new Mail();
						$mailrose->setTo('rmjuteau@gmail.com');
						$array=array();	
						$array['vendor']=$_SESSION['vendor']['nom'];
						$array['password']=$_POST['pass'];
						$array['login']=$_POST['login'];
						$mailrose->setContent(login, $array);
						$mailrose->setSubject('Modification de login et mot de passe');
						$mailrose->send();
				}
				elseif ((empty($_POST['pass']))&&($_SESSION['vendor']['email']!=$_POST['login'])) {
						$mail = new Mail();
						$mail->setTo('admin@e-citizen.com');
						$array['vendor']=$_SESSION['vendor']['nom'];
						
						$array['login']=$_POST['login'];
						
						$mail->setContent(login, $array);
						
						
						
						$mail->send();
						
						$mailrose= new Mail();
						$mailrose->setTo('rmjuteau@gmail.com');
						$array=array();	
						$array['vendor']=$_SESSION['vendor']['nom'];
						
						$array['login']=$_POST['login'];
						$mailrose->setContent(login, $array);
						$mailrose->setSubject('Modification de login');
						$mailrose->send();
				
				}
			
			
			$_SESSION['vendor']['email']=$_POST['login'];
			if(!empty($_POST['tva'])){
				if ($_POST['tva']=='non'){$_SESSION['vendor']['tva']=0;}
				if ($_POST['tva']=='oui'){$_SESSION['vendor']['tva']=1;}
			}
			if(!empty($_POST['pays'])){
				$_SESSION['vendor']['pays_id']=$_POST['pays'];
			}
			if(!empty($_POST['email2'])){
				$_SESSION['vendor']['email2']=$_POST['email2'];
			}
			if(!empty($_POST['email3'])){
				$_SESSION['vendor']['email3']=$_POST['email3'];
			}
			
			$_SESSION['vendor']->save();
	}
	


if (!empty($_POST['save2'])) {

		if ((!empty($_POST['pass']))&&(!empty($_POST['pass2']))&&($_POST['pass']==$_POST['pass2'])&&($_SESSION['sharing']['email']==$_POST['login'])) {

						$mail = new Mail();
						$mail->setTo('admin@e-citizen.com');
						$array=array();
						$array['sharing']=$_SESSION['sharing']['name'];
						$array['password']=$_POST['pass'];
						
						$mail->setContent(login, $array);
						
						$mail->setSubject('Modification de mot de passe');
						$mail->send();

					
				}
				elseif ((!empty($_POST['pass']))&&(!empty($_POST['pass2']))&&($_POST['pass2']==$_POST['pass'])&&($_SESSION['sharing']['email']!=$_POST['login'])){
						$mail = new Mail();
						$mail->setTo('admin@e-citizen.com');
						$array=array();
						$array['sharing']=$_SESSION['sharing']['name'];
						$array['password']=$_POST['pass'];
						$array['login']=$_POST['login'];
						$mail->setContent(login, $array);
						
						$mail->setSubject('Modification de login et mot de passe');
						$mail->send();
				}
				elseif (((empty($_POST['pass']))||(empty($_POST['pass2'])))&&($_SESSION['sharing']['email']!=$_POST['login'])) {
						$mail = new Mail();
						$mail->setTo('admin@e-citizen.com');
						$array=array();
						$array['sharing']=$_SESSION['sharing']['name'];
						
						$array['login']=$_POST['login'];
						$mail->setContent(login, $array);
						$mail->setSubject('Modification de login');
						$mail->send();
				
				}


	
		$_SESSION['sharing']['name']=$_POST['name'];
		$_SESSION['sharing']['email']=$_POST['login'];
		if ((!empty($_POST['pass']))&&(!empty($_POST['pass2']))) {
					$_SESSION['sharing']['password']=md5($_POST['pass']);
				}
		$_SESSION['sharing']->save();
	

}














?>